package com.practice.chatroom;

import com.practice.chatroom.Deal.HttpStatusCode;

/** 自定义业务类异常，用于抛出要返回给前台展现提示的错误，应有一处统一做catch */
public class AppException extends Exception {

    /** 错误对应的http响应状态码 */
    public HttpStatusCode errorCode;

    /**
     * 以400响应码实例化一个业务异常
     * 
     * @param msg 提示信息
     */
    public AppException(String msg) {
        super(msg);
        this.errorCode = HttpStatusCode.BAD_REQUEST_400;
    }

    /**
     * 实例化一个业务异常
     * 
     * @param msg       提示信息
     * @param errorCode 错误状态码，应为4打头的
     * @see Deal.HttpStatusCode
     */
    public AppException(String msg, HttpStatusCode errorCode) {
        super(msg);
        this.errorCode = errorCode;
    }
}